1 package jrre.gui;
2
3 import jrre.JRRE;
4 import java.awt.*;
5 import javax.swing.*;
6 import javax.swing.tree.*;
7 import java.awt.event.*;
8
9 public class JavaStackFrameGui extends JFrame {
10
11 private static JTree methodAreaTree = new JTree();
12 private static DefaultMutableTreeNode treeRoot;
13 private static DefaultMutableTreeNode frameRoot;
14
15 private static DefaultTreeModel treeModel;
16 private static int classCount = 0;
17
18 private static java.util.Vector frameVector = new java.util.Vector();
19
20 public JavaStackFrameGui(){
21
22 super("Java Stack");
23
24 classCount = 0;
25
26 // Set up and add tree.
27 treeRoot = new DefaultMutableTreeNode("Java Stack");
28 treeModel = new DefaultTreeModel(treeRoot);
29
30 methodAreaTree = new JTree(treeModel);
31
32 JPanel treePanel = new JPanel();
33 treePanel.add(methodAreaTree);
34
35 JScrollPane scrollPane = new JScrollPane(methodAreaTree);
36 //scrollPane.add(methodAreaTree);
37 Container content = getContentPane();
38 content.add(scrollPane);
39
40 addWindowListener(new WindowDestroyer());
41
42 setSize(300,300);
43 setLocation(400, 0);
44
45 if(JRRE.guiOn())
46 setVisible(true);
47 }
48
49 public void clear(){
50
51 classCount = 0;
52 treeRoot.removeAllChildren();
53 frameRoot = treeRoot;
54 }
55
56 public static void push(String className){
57
58 //frameVector.add(frameRoot);
59
60 treeRoot.setUserObject("Java Stack: "+(++classCount));
61 DefaultMutableTreeNode classToAdd = new DefaultMutableTreeNode(className);
62 //frameRoot = classToAdd;
63
64 treeRoot.add(classToAdd);
65 treeModel.reload();
66
67 TreePath path = new TreePath(classToAdd.getPath());
68 methodAreaTree.expandPath(path);
69
70 }
71
72 public static void pop(){
73
74 treeRoot.setUserObject("Java Stack: "+(--classCount));
75 treeRoot.remove(treeRoot.getChildCount()-1);
76
77 treeModel.reload();
78
79 }
80
81 class WindowDestroyer extends WindowAdapter{
82 public void windowClosing(WindowEvent e){
83 System.exit(0);
84 }
85 }
86
87 }
88
This page was automatically generated by Maven